/**
 * @Author 天下无敌
 * @Date 
 * @AIDE AIDE+ 
 */
package com.ecs.core.gsystem.draw;
import com.artemis.annotations.All;
import com.artemis.systems.IteratingSystem;
import com.artemis.ComponentMapper;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.ecs.core.components.draw.AnimationCom;
import com.ecs.core.components.draw.SpriteRender;

@All({AnimationCom.class,SpriteRender.class})
public class AnimationSystem extends IteratingSystem
{
	public static final String TAG = "AnimationSystem";
	private ComponentMapper<AnimationCom> animations;
	private ComponentMapper<SpriteRender> sprites;

	@Override
	protected void process(int p)
	{
		AnimationCom a = animations.get(p);
		SpriteRender s = sprites.get(p);
		
		a.stateTime += world.getDelta();
		String curretnState = a.currentAnimation;
		Animation<TextureRegion> atg = a.animations.get(curretnState);
		
		s.region = atg.getKeyFrame(a.stateTime);

		
	}

}
